Skip to content

Add hypothesis property-based roundtrip tests for all Pydantic models - #39

Merged
mehmetkr merged 1 commit into
mainfrom
tests/hypothesis-roundtrip
Dec 4, 2026
Merged

mehmetkr merged 1 commit into
mainfrom
tests/hypothesis-roundtrip

Conversation

@mehmetkr

@mehmetkr mehmetkr commented Dec 4, 2026

Copy link
Copy Markdown
Owner

Summary

  • Adds property-based roundtrip tests using Hypothesis for all 95 _ApiModel subclasses across 10 type modules
  • Dict roundtrip: model_validate(model_dump(by_alias=True)) == instance verifies Python-level serialization fidelity
  • JSON stability: model_dump_json → model_validate_json → model_dump_json verifies wire-format idempotency
  • Custom recursive strategy builder handles all field types: AwareDatetime, dict[str, Any], Literal, Annotated with constraints (Ge, Le, MinLen, MaxLen), nested BaseModel subclasses, Union/Optional
  • 190 parametrized test cases (95 models x 2 properties), 50 examples each = 9,500 property checks

Test plan

  • All 190 hypothesis tests pass
  • Full test suite passes (584 tests)
  • Local CI checks clean (ruff, pyright, pytest)
  • Adversarial audit: clean PASS across all dimensions (correctness, coverage, constraint handling, elite quality)

@mehmetkr
mehmetkr merged commit 6176d64 into main Dec 4, 2026
7 checks passed
@mehmetkr
mehmetkr deleted the tests/hypothesis-roundtrip branch December 4, 2026 08:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant